<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查看油卡</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">
    <style>
        .layui-form-select dl{
            max-height: 100px; //原值为300，调节高度建议为50的倍数
        }
    </style>
</head>
<body  >
<div class="layui-container">


    <form class="layui-form">
        <div class="layui-row">
            <div class="layui-col-md12">

                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>查看油卡</legend>



                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label"><span style="color: red;">*</span>油卡号</label>
                            <div class="layui-input-inline" style="width: 140px;">
                                <input   type="text" name="ykh"  lay-verify="required" required   class="layui-input" id="ykh" >
                                <input   type="hidden" name="ykid"    id="ykid" >
                                <input   type="hidden" name="isU"    id="isU"   >
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label"><span style="color: red;">*</span>加油站</label>
                            <div class="layui-input-inline" style="width: 140px;">
                                <select   type="text" name="jyz"  lay-verify="required" required   class="layui-input" id="jyz" >
                                    <option value=""></option>
                                    <option value="中石油">中石油</option>
                                    <option value="中石化">中石化</option>
                                    <option value="其他">其他</option>
                                </select>
                            </div>
                        </div>


                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px;"><span style="color: red;">*</span>购卡日期</label>
                            <div class="layui-input-inline" style="width: 140px;">
                                <input   type="text" name="gkrq"  lay-verify="required" required   class="layui-input" id="gkrq" lay-filter = "gkrq">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px;"><span style="color: red;">*</span>油卡类别</label>
                            <div class="layui-input-inline" style="width: 140px;">
                                <div class="layui-input-inline layui-form" style="width: 140px;">
                                    <select name="yklb" lay-verify="required" required lay-search   id="yklb"  lay-filter="yklb"	 style="width: 150px;" >
                                        <option value="固定卡">固定卡</option>
                                        <option value="备用卡">备用卡</option>
                                        <option value="其他">其他</option>
                                    </select>
                                </div>
                            </div>
                        </div>



                    </div>



                </fieldset>
            </div>
        </div>


        <button type="button" class="layui-btn layui-btn-normal"  id="modiInfo" style="width: 10%; position: absolute;left: 55%" >修改信息</button>
        <button id="modiSub" class="layui-btn layui-btn-normal layui-btn-disabled" disabled lay-submit lay-filter="update" style="width: 10%; position: absolute;left: 35%"  >立即提交</button>
    </form>
</div>
<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/jquery.js"></script>
<script src="../js/jquery.md5.js"></script>
<script src="../js/tools.js"></script>

<script>
    layui.use(['table','form','layer','laydate','upload'],function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var upload = layui.upload;
        $(".layui-input").addClass("layui-disabled");
        $(".layui-input").attr("disabled",true);
        $("select").attr("disabled","disabled");
        //校验
        //校验

//日期控件渲染
        laydate.render({
            elem: '#gkrq' //指定元素
            ,theme:'#0099FF'
            ,value: getFormatDate()
            ,type: 'date'
            ,format:'yyyy-MM-dd'
        });

        if($("#isU").val() == "false"){
            $("#modiInfo").attr("disabled",true);
            $("#modiInfo").addClass("layui-btn-disabled");
        }

        $("#modiInfo").on('click',function(){

            $("#modiSub").removeClass("layui-btn-disabled");
            $("#modiSub").removeAttr("disabled");

            $("#modiInfo").addClass("layui-btn-disabled");
            $("#modiInfo").attr("disabled",true);

            $(".layui-input").removeClass("layui-disabled");
            $(".layui-input").attr("disabled",false);
            $("select").removeClass("layui-disabled");
            $("select").removeAttr("disabled");
            form.render('select');
        });


//渲染部门
        $.ajax({
            url: contextPath+"/dept/" ,
            type: "GET",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            success: function(res) {
                console.log(res);
                for(var i in res.list){
                    if($("#ssbmHid").val() ==  res.list[i].bumenid){
                        var option = "<option selected value='"+ res.list[i].bumenid+ "'>"+res.list[i].name+"</option>";
                    }else {
                        var option = "<option value='"+ res.list[i].bumenid+ "'>"+res.list[i].name+"</option>";
                    }


                    $("#ssbm").append(option);
                };
                form.render('select');
            }
        });



        form.on('submit(update)', function(data){
            console.log(data.field);

            $("input").css("border","");
            $.ajax({
                url: contextPath+"/oilcard",
                type: "PUT",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    updateSuccess($,layer,res)
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
</body>
</html>